package org.jit.sose;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@EnableZuulProxy // 开启zuul网关
@EnableDiscoveryClient
@SpringBootApplication
public class AppZuul {

	public static void main(String[] args) {
		SpringApplication.run(AppZuul.class, args);
	}

	// zuul配置能够使用config实现实时更新
	@RefreshScope
	@ConfigurationProperties(prefix = "zuul") // 去读取zuul开头的配置信息
	public ZuulProperties zuulProperties() {
		return new ZuulProperties();
	}

	// 添加文档来源
//	@Component
//	@Primary
//	class DocumentationConfig implements SwaggerResourcesProvider {
//		@Override
//		public List<SwaggerResource> get() {
//			List<SwaggerResource> resources = new ArrayList<>();
//			// app-itmayiedu-order
//			resources.add(swaggerResource("会员服务", "/api-member/v2/api-docs", "1.0"));
//			resources.add(swaggerResource("订单服务", "/api-order/v2/api-docs", "2.0"));
//			return resources;
//		}
//
//		/**
//		 * 
//		 * @param name
//		 * @param location 服务在zuul配置文件中的path
//		 * @param version
//		 * @return
//		 */
//		private SwaggerResource swaggerResource(String name, String location, String version) {
//			SwaggerResource swaggerResource = new SwaggerResource();
//			swaggerResource.setName(name);
//			swaggerResource.setLocation(location);
//			swaggerResource.setSwaggerVersion(version);
//			return swaggerResource;
//		}
//	}

}
